# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=megacmd
_projname=MEGAcmd
pkgver=1.6.3
pkgrel=0
pkgdesc="Command Line Interactive and Scriptable Application to access MEGA"
url="https://github.com/meganz/megacmd"
# s390x,x86: blocked by megasdk-dev
arch="all !s390x !x86"
license="BSD-2-Clause AND GPL-3.0-or-later"
makedepends="
	autoconf
	autoconf-archive
	automake
	libtool
	megasdk-dev
	readline-dev
	"
subpackages="$pkgname-bash-completion"
source="https://github.com/meganz/MEGAcmd/archive/refs/tags/${pkgver}_Linux/$_projname-$pkgver.tar.gz
	xdg_data_home.patch
	unbundle-sdk.patch
	"
builddir="$srcdir/$_projname-${pkgver}_Linux"
options="!check"  # tests require account on MEGA

prepare() {
	default_prepare

	sed -i 's|/bin/bash|/bin/sh|' src/client/mega-*

	./autogen.sh
}

build() {
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var
	make
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
425584a1350e5965aea8a09076bb447b4d6a00fc0305e9a19ad91ed8292eae5b758e4c1a41ea7c0887c2f8e0644cf1d1154e3b33503ddcf4713e4a13dd80a6f6  MEGAcmd-1.6.3.tar.gz
433c19dfe66b3c8c90790ced05bd7d5ad5153ff0ac129acb2fa75ba0eb5d6c95186fed4ad0e64bd892e809aed5fd99e71ecc804d37a4aabb05afd2f29f233bef  xdg_data_home.patch
928278c690dda0ff1244c69a6a0121eaeb21a1b8e6387281a30a1ee3599173b0a3485cad1a23133a5dced9af5653aea19ee1a6727c7e3da0550cce6a6016321e  unbundle-sdk.patch
"
